package com.fancy.learncenter.ui.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.fancy.learncenter.R;
import com.fancy.learncenter.bean.StudentWorkAnsDataBean;
import com.fancy.learncenter.ui.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.ui.adapter.base.CustomViewHold;

import java.util.List;

/**
 * Created by hyy on 2018/4/24.
 */

public class CartoonStudentWorkListenPicListAdapter extends CommonRecycleViewAdapter<StudentWorkAnsDataBean.ResultBean> {

    public CartoonStudentWorkListenPicListAdapter(Context mContext, List<StudentWorkAnsDataBean.ResultBean> itemDatas) {
        super(mContext, R.layout.cartoon_student_work_item, itemDatas);
    }

    @Override
    public void bindView(CustomViewHold customViewHold, StudentWorkAnsDataBean.ResultBean item, int position) {

        TextView ans_state = customViewHold.getView(R.id.ans_state);
        TextView ans_tv = customViewHold.getView(R.id.ans_tv);

        if ("0".equals(item.getQuestionState())) {
            ans_state.setText("错误");
            ans_state.setTextColor(Color.parseColor("#FA1733"));
        } else {
            ans_state.setText("正确");
            ans_state.setTextColor(Color.parseColor("#00c9b9"));
        }

        SimpleDraweeView simpleDraweeView = customViewHold.getView(R.id.simpleDraweeView);

        if ("0".equals(item.getAnswerResources().get(0).getResourceType())) {
            simpleDraweeView.setVisibility(View.GONE);
            ans_tv.setText(item.getAnswerResources().get(0).getResourceValue());
        } else {
            simpleDraweeView.setVisibility(View.VISIBLE);
            simpleDraweeView.setImageURI(item.getAnswerResources().get(0).getResourceValue());
        }

    }
}
